import { encrypt as ee,decrypt as dd } from "./crypto/crypto.js";
import { randomString } from "./math/math.js";

const kUserName = 'cxx';
const kPassword = 'abc123456';
let token;

export function login(psd, name=kUserName) {
    if (name !== kUserName) {
        alert('用户名错误');
        return;
    }
    if (kPassword !== psd) {
        alert('密码错误');
        return;
    }
    token = randomString();
    return token;
}

export function encrypt(message) {
    return ee(message);
}

export function decrypt (message) {
    return dd(message);
}

let origin = "1234567890你好吗Hello";
let s1 = encrypt(origin);
console.log(`>>> s1: ${s1}`);
let s2 = decrypt(s1);
console.log(`>>> s2: ${s2}`);
